package com.cdsxt.util;

import java.util.Map;

public class JdbcUtil {
	
	/**
	 * 通过jdbc类型获取java类型
	 * 
	 *映射表
	 *
	 *TINYINT	Byte
	 *SMALLINT	Short
	 *INT	Integer
	 *INTEGER	Integer
	 *BIGINT	Long
	 *
	 *CHAR	String
	 *VARCHAR	String
	 *
	 *TINYTEXT	String
	 *TEXT	String
	 *LONGTEXT	String
	 *
	 *DATE	Date
	 *TIME	Date
	 *DATETIME	Date
	 *TIMESTAMP	Date
//	 */
	//全部转换为小写
	@SuppressWarnings("unchecked")
	private static Map<String,String> typeMap=MapPlus.build()
			.putSelf("TINYINT", "Byte")
			.putSelf("SMALLINT", "Short")
			.putSelf("INT", "Integer")
			.putSelf("INTEGER", "Long")
			.putSelf("BIGINT", "String")
			.putSelf("CHAR", "String")
			.putSelf("VARCHAR", "String")
			.putSelf("TINYTEXT", "String")
			.putSelf("TEXT", "String")
			.putSelf("LONGTEXT", "String")
			.putSelf("DATE", "Date")
			.putSelf("TIME", "Date")
			.putSelf("DATETIME", "Date")
			.putSelf("TIMESTAMP", "Date");
	public static String getJavaTypeforMysqlType(String mysqlType) {
		String javaType = typeMap.get(mysqlType.toUpperCase());
		return javaType;
	}
	
}
